
from rasa_sdk import Tracker, Action
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction
from rasa_sdk.types import DomainDict
from typing import Dict, Text, Any, List, Union
from actions.third_weather import get_weather


class WeatherForm(FormAction):

    def name(self):
        return 'weather_form'

    @staticmethod
    def required_slots(tracker: Tracker) -> List[Text]:
        return ['address']

    def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: DomainDict
    ):
        address = tracker.get_slot('address')
        weather_data = get_weather(address)
        dispatcher.utter_message(weather_data)

        return []
